<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>提现申请</title>
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<meta name="format-detection" content="telephone=no">
<script src="__PUBLIC__/wap/js/flexible.js"></script>
<link href="__PUBLIC__/wap/css/icons.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/base.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/wap/css/member.css" />
</head>
<body class="cash" ontouchstart="" onmouseover="" class="login">
<div class="head">
	<a href="javascript:history.go(-1);" class="md-close back" >
	<i class="iconfont">&#xe617</i>
	</a>
	<h2 >提现申请</h2>
</div>

<div class="page greenbg">

<div class="tip">亲，要余额最低满100，且提现额度必须是满百的整数，才可以进行提现操作喔，提现要加收5%的手续费喔。</div>
	<if condition="$list['0']['auid_status1'] eq 2">
<div class="notice">
			{$list['0'].remarks1}
            </div>
	</if>
	<if condition=" $list['0']['auid_status2'] eq 2">
    <div class="notice">

			{$list['0'].remarks2}
            </div>
	</if>



<div class="newbox">
	
    <div class="bankcard mlogin mgt2">

	<div class="field">
		<div class="label">
			可提现额
		</div>
		<div class="field-control">
			<input class='input-required green' value="￥{$data.balance}" type="text" value="" disabled>
		</div>
	</div>
	<div class="field">
		<div class="label">
			提现金额
		</div>
		<div class="field-control">
			<input type="text" class="input-required green" id="input-money" placeholder="请输入您要提现的金额" value="{$cash_apply_min_money}" >
		</div>
	</div>
	<div class=" cardlist">
		<if condition="$data['balance'] gt 0 && $data['balance'] egt $cash_apply_min_money " >
			<if condition="empty($bank_list)" >
				<a href="{:U('wap/member/bank_account_add',array('type'=>'cashapply'))}">
				<div class="submit" style="position:static">
					<button type="button" href="javascript: void(0);" class="button phone_binding_btn">添加提现账户</button>
				</div>
				</a>
				<else/>
				<volist name="bank_list" id="vo">
					<div class="card acc_{$vo.id} {$vo['is_default']?'on' :''} "  data-id="{$vo.id}" >
						<div class="title">
							{$vo.account_name}<span class="num floatRgt">{$vo.account_no}</span>
						</div>
						<div class="info">
							<div class="add">
								{$vo.account_bank}-{$vo.account_addr}
							</div>
							<span > {$vo['is_default']?'<span class="new-icon"></span>':''} </span>
							<div class="option">
								<a href="{:U('wap/member/bank_account_add',array('id'=>$vo['id']))}" class="btn1 btnsF34">
								编辑
								</a>
								<a href="javascript:void(0);" data="{$vo.id}" onclick="delclick(this);" class="btn2 btnsF34" >
								删除
								</a>
							</div>
						</div>
					</div>
				</volist>
			</if>
		</if>
	</div>
</div></div>	<if condition="$list['empty'] eq 1">
	<div class="list">
		<div class="title">
			<a href="{:U('wap/member/cashapply_detail')}">
			<i class="iconfont icon" style="color:#f9960f">&#xe633</i><span>提现明细</span>
			<i class="iconfont floatRgt">&#xe611</i>

			</a>
		</div>
	</div>
	</if>
	<if condition="$data['balance'] gt 0 && $data['balance'] egt $cash_apply_min_money " >
		<if condition="empty($bank_list)" >
			<else/>
			<form id="withdraw" role="form" class="mlogin " action="" method="post" novalidate onSubmit="return false;">
				<!--提现帐号，提现金额-->
				<input  name="bank_account_id" id="bank_account_id"  type="hidden" value="{$default_bank.id}" >
				<input type="hidden" class="input-required" name="money"  value="{$cash_apply_min_money}" id="money">
				<div class="submit submitdown">
					<a href="javascript:void(0);" class=" phone_log_btn">
					<button type="button" class="button " id="submit-btn">提 现</button>
					</a>
				</div>
			</form>
		</if>
		<else/>
	</if>




</div>
<include file="Public/footer_new" />
<script type="text/javascript" src="__PUBLIC__/wap/js/jquery.min.js"></script>
<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.wap.js"></script>
<script src="__PUBLIC__/js/jquery.form.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
<script>
	jQuery(document).ready(function() {
		//FormValidator.init();
		jQuery.validator.addMethod("byteRangeLength", function(value) {
			var dropdown=$("#dropdown").val();
			var ret=true;
			if(dropdown>0){
				if(!value){
					ret=false;
				}
			}
			return ret;
		});

		$("#withdraw").validate({
			rules: {
				bank_account_id:'required',
				money:{
					required:true,
					number:true,
					min:"<?php echo $cash_apply_min_money; ?>",
					max:"<?php echo $data['balance']; ?>"
		}
	},
		messages: {
			bank_account_id:'<span class="icon-warning icon_warning"></span>&nbsp;请选择提现帐号',
					money:{
						required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入提现金额',
						number:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的金额',
						min:'<span class="icon-warning icon_warning"></span>&nbsp;提现金额不能小于<?php echo $cash_apply_min_money; ?>',
						max:'<span class="icon-warning icon_warning"></span>&nbsp;提现金额不能大于余额￥<?php echo $data['balance']; ?>'
			}
		},
		focusInvalid:false,
				success: function(label) {
			// set  as text for IE 
			// alert('ok'); 
			//label.html(" ").addClass("checked"); 
		},
		/*执行ajaxsubmit  */
		submitHandler: function(editform) {
			var options = {
				url :"<?php echo U('Wap/Member/cashapply_add'); ?>",
				type :"post" ,
				dataType:'json',
				target : "#loader",
				error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});},
				onwait : "正在处理信息，请稍候...",
				success: function(res){
					console.log(res);
					//$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
					//$('#editform').hide(2000); 
					if(res.status==1){
						layer.msg("操作成功",{icon:6,time:1500},function(){
							window.location.href="<?php echo U('Wap/Member/cashapply'); ?>";
						});

					}else{
						layer.msg(res.error,{icon:5});
					}
				}
			};
			setTimeout((function(opt){
				return function(){
					$('#withdraw').ajaxSubmit(opt);
				}
			})(options), 300);
			return false;
		}

	});

		$('#submit-btn').click(function(){
			$('#withdraw').submit();
		});

		$('.card').click(function(){
			var data_id=$(this).attr("data-id");
			$("#bank_account_id").val(data_id);
			$('.card').removeClass('on');
			$(this).addClass('on');
		});
		$('#input-money').change(function () {
			var money=$(this).val();
			$('#money').val(money);
		});

	});
	//删除
	function delclick(dom){
		if(confirm('确定删除该提现帐号')){
			var pv=$(dom).attr('data');
			$.ajax({
				url: "{:U('wap/member/bank_account_del')}",
				type:'post',
				data: {id:pv},
				dataType: 'json',
				success: function(data){
					//console.log(data);
					if(data.status==1){
						//成功
						layer.msg('删除成功', {icon: 6});
						$('.acc_'+pv).remove();
					}else{
						layer.msg(data.error, {icon: 5});
						//alert(data.error);
					}
				}
			});
		}

	}
</script>
</body>
</html>